home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performBevelPlus.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  28.6 KB  |  1,064 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // Copyright (C) 1997-2001 Alias|Wavefront,
  18. // a division of Silicon Graphics Limited.
  19. //
  20. // The information in this file is provided for the exclusive use of the
  21. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  22. // and incorporate this code into other products for purposes authorized
  23. // by the Alias|Wavefront license agreement, without fee.
  24. //
  25. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  26. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  27. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  28. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  29. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. // PERFORMANCE OF THIS SOFTWARE.
  32. //
  33. //
  34. //  Alias|Wavefront Script File
  35. //  MODIFY THIS AT YOUR OWN RISK
  36. //
  37. //
  38. //  Description:
  39. //      This script is defines the option box for the bevel plus
  40. //        surface menu item.
  41. //
  42. //  Input Arguments:
  43. //      int action
  44. //          0 - show the option box dialog
  45. //        1 - just execute the bevel plus operation
  46. //
  47. //  Return Value:
  48. //      None.
  49. //
  50.  
  51. // OK, this is a problem.  We'd like to get this mapping
  52. // directly from the attributes on styleCurve node, but
  53. // there is currently no MEL way of doing that.
  54. global string $BSstyleCurveStrings[] = { "Straight Out",
  55.                                          "Straight In",
  56.                                          "Convex Out",
  57.                                          "Convex In",
  58.                                          "Concave Out",
  59.                                          "Concave In",
  60.                                          "Straight Side Edge",
  61.                                          "Straight Front Edge",
  62.                                          "Straight Corner",
  63.                                          "Convex Side Edge",
  64.                                          "Convex Front Edge",
  65.                                          "Convex Corner",
  66.                                          "Concave Side Edge",
  67.                                          "Concave Front Edge",
  68.                                          "Convex Crease" };
  69.  
  70. global proc bevelPlusVisibility()
  71. //  Description:
  72. //        Dim/show any bevel options as required by the output surface type
  73. //
  74. {
  75.     int $surfType;
  76.     if ( `radioButtonGrp -exists outputPolyRadioButtonGrp` ) {
  77.         $surfType = `radioButtonGrp -q -select outputPolyRadioButtonGrp`;
  78.     } else {
  79.         $surfType = `optionVar -q bevelPlusOutputPolygons`;
  80.     }
  81.  
  82.     // only enable attach and tolerance if in nurbs/bezier mode
  83.     if(2 == $surfType) { // 2 == Poly
  84.         checkBoxGrp -e -en 0 bevelPlusJoinSrfBox;
  85.         radioButtonGrp -e -en 0 useGlobalTol;
  86.         tabLayout        -e -en 0 useGlobalTolTab;
  87.     } else {  // Nurbs, enable attach option and the tolerance
  88.         checkBoxGrp -e -en 1 bevelPlusJoinSrfBox;
  89.         radioButtonGrp -e -en 1 useGlobalTol;
  90.         tabLayout        -e -en 1 useGlobalTolTab;
  91.     }
  92. }
  93.  
  94. proc int getStyleCurveIndex( string $name )
  95. {
  96.     global string $BSstyleCurveStrings[];
  97.     int $cmdIndex = 0;
  98.  
  99.     string $str;
  100.     for( $str in $BSstyleCurveStrings ) {
  101.         if( $str == $name ) break;
  102.         $cmdIndex++;
  103.     }
  104.     return $cmdIndex;
  105.  
  106. proc setOptionVars (int $forceFactorySettings)
  107. {
  108.     bevelPlusSetOptionVars( $forceFactorySettings );
  109. }
  110.  
  111. proc updateBevelSideEnableState()
  112. {
  113.     //setParent NewBevelOptionBox2;
  114.  
  115.     int $bevelSideAtStart, $bevelSideAtEnd;
  116.     int $bevelCapAtStart, $bevelCapAtEnd;
  117.     int $sameAsOuterStyle, $enable, $enableInnerStyle;
  118.  
  119.     //    Get the bevel side selection.
  120.     //
  121.     $bevelSideAtStart = `checkBoxGrp -q -v1 BevelSideCheckBoxGroup`;
  122.     $bevelSideAtEnd = `checkBoxGrp -q -v2 BevelSideCheckBoxGroup`;
  123.  
  124.     //    Get the bevel cap selection.
  125.     //
  126.     $bevelCapAtStart = `checkBoxGrp -q -v1 BevelCapCheckBoxGroup`;
  127.     $bevelCapAtEnd = `checkBoxGrp -q -v2 BevelCapCheckBoxGroup`;
  128.     
  129.     $sameAsOuterStyle = `checkBoxGrp -query -value1 BevelInnerStyleCheckBoxGroup`;
  130.  
  131.     $enable = true;
  132.     if ($sameAsOuterStyle) {
  133.         $enableInnerStyle = false;
  134.     } else {
  135.         $enableInnerStyle = true;
  136.     }
  137.  
  138.     floatSliderGrp -edit -enable $enable BevelWidthSliderGroup;
  139.     floatSliderGrp -edit -enable $enable BevelDepthSliderGroup;
  140.  
  141.     textScrollList -edit -enable $enable BevelOuterStyleTextScrollList;
  142.  
  143.     checkBoxGrp -edit -enable $enable BevelInnerStyleCheckBoxGroup;
  144.  
  145.     textScrollList -edit -enable $enableInnerStyle BevelInnerStyleTextScrollList;
  146. }
  147.  
  148. global proc BevelSideCheckBoxChange()
  149. {
  150.     updateBevelSideEnableState();
  151. }
  152.  
  153. proc updateInnerStyleEnableState()
  154. {
  155.     int $sameAsOuterStyle, $enable;
  156.  
  157.     $sameAsOuterStyle = `checkBoxGrp -query -value1 BevelInnerStyleCheckBoxGroup`;
  158.  
  159.     if ($sameAsOuterStyle) {
  160.         $enable = false;
  161.     } else {
  162.         $enable = true;
  163.     }
  164.  
  165.     textScrollList -edit -enable $enable BevelInnerStyleTextScrollList;
  166. }
  167.  
  168. global proc BevelInnerStyleCheckBoxChange()
  169. {
  170.     updateInnerStyleEnableState();
  171. }
  172.  
  173. proc string createBevelOptions(string $parent)
  174. //
  175. //    Description :
  176. //        Bevel plus operation options
  177. //
  178. {
  179.     global string $BSstyleCurveStrings[];
  180.  
  181.     setParent $parent ;
  182.     
  183.     string $column = `columnLayout/* -rowSpacing 2 -adjustableColumn true*/`;
  184.  
  185.     checkBoxGrp -ncb 1 -l "" -l1 "Attach Surfaces" -v1 on bevelPlusJoinSrfBox;
  186.  
  187.     // Create Bevel
  188.     //
  189.     checkBoxGrp -numberOfCheckBoxes 2
  190.             -label "Create Bevel"
  191.             -labelArray2 "At Start" "At End"
  192.             -cc1 ("BevelSideCheckBoxChange")
  193.             -cc2 ("BevelSideCheckBoxChange")
  194.             BevelSideCheckBoxGroup;
  195.  
  196.     // Sliders
  197.     //
  198.     floatSliderGrp -l "Bevel Width"
  199.         -min 0.00001 -max 0.25 -fmn -10000.0 -fmx 10000.0
  200.         BevelWidthSliderGroup;
  201.     floatSliderGrp -l "Bevel Depth"
  202.         -min 0.00001 -max 0.25 -fmn -10000.0 -fmx 10000.0
  203.         BevelDepthSliderGroup;
  204.     floatSliderGrp -l "Extrude Distance"
  205.         -min 0.00001 -max 1.0 -fmn -10000.0 -fmx 10000.0
  206.         extrudeDepthFloatField;
  207.  
  208.     // Caps
  209.     //
  210.     checkBoxGrp -numberOfCheckBoxes 2
  211.             -label "Create Cap"
  212.             -labelArray2 "At Start" "At End"
  213.             -cc1 ("BevelSideCheckBoxChange")
  214.             -cc2 ("BevelSideCheckBoxChange")
  215.             BevelCapCheckBoxGroup;
  216.  
  217.     // Style curve scroll lists
  218.     //
  219.     separator;
  220.  
  221.     rowLayout -numberOfColumns 2;
  222.     text -label "Outer Bevel Style";
  223.     textScrollList -numberOfRows 8 BevelOuterStyleTextScrollList;
  224.     setParent ..;
  225.  
  226.     rowLayout -numberOfColumns 2;
  227.     text -label "Inner Bevel Style";
  228.     textScrollList -numberOfRows 8 BevelInnerStyleTextScrollList;
  229.     setParent ..;
  230.  
  231.     string $str;
  232.     for ($str in $BSstyleCurveStrings) {
  233.         textScrollList -e -append $str BevelOuterStyleTextScrollList;
  234.         textScrollList -e -append $str BevelInnerStyleTextScrollList;
  235.     }
  236.  
  237.     checkBoxGrp -numberOfCheckBoxes 1
  238.         -label "" -label1 "Same as Outer Style"
  239.         -value1 true
  240.         -changeCommand ("BevelInnerStyleCheckBoxChange")
  241.         BevelInnerStyleCheckBoxGroup;
  242.  
  243.     separator;
  244.  
  245.     // Misc. options
  246.     //
  247.  
  248.     radioButtonGrp -nrb 2 -l "Use Tolerance"
  249.        -l1 "Global"
  250.        -l2 "Local"
  251.        -on1 "tabLayout -e -selectTab noSlider useGlobalTolTab"
  252.        -on2 "tabLayout -e -selectTab showSlider useGlobalTolTab"
  253.        useGlobalTol;
  254.  
  255.     tabLayout -tabsVisible false useGlobalTolTab;
  256.        columnLayout showSlider;
  257.             floatSliderGrp -l "Tolerance"
  258.                  -min 0.00001 -max 0.1 -fmn 0.00001 -fmx 1000.0
  259.                 bevelPlusToleranceFloatField;
  260.        setParent ..;
  261.        columnLayout noSlider;
  262.        setParent ..;
  263.     setParent ..;
  264.  
  265.     bevelPlusVisibility();
  266.     updateBevelSideEnableState();
  267.     updateInnerStyleEnableState();
  268.  
  269.     return $column;
  270. }
  271.  
  272. proc bevelPlusPolySetup( string $parent )
  273. {
  274. }
  275.  
  276. global proc bevelPlusPolyVisibility( string $parent, int $format )
  277. {
  278.     setParent $parent;
  279.     switch( $format ) {
  280.       case 0:
  281.       default:
  282.         tabLayout -e -selectTab tabCount formatTabs;
  283.         break;
  284.       case 2:
  285.         tabLayout -e -selectTab tabGeneral formatTabs;
  286.         break;
  287.     }
  288. }
  289.  
  290. proc bevelPlusPolyAddOptions( string $parent )
  291. {
  292.     setParent $parent;
  293.  
  294.     string $radioBtnGrp1 =`radioButtonGrp
  295.         -nrb 2
  296.         -label "Tessellation Method"
  297.         -l1 "Count"
  298.         -l2 "Sampling"
  299.         -cc1 ("bevelPlusPolyVisibility " + $parent + " 0")
  300.         -cc2 ("bevelPlusPolyVisibility " + $parent + " 2")
  301.         format`;
  302.  
  303.     separator -w 1000; 
  304.  
  305.     tabLayout -tabsVisible false formatTabs;
  306.  
  307.         columnLayout tabGeneral;
  308.             text -l " Sampling Controls";
  309.  
  310.             optionMenuGrp -l "Along Extrusion" uType;
  311.                 menuItem -l "Complete";
  312.                 menuItem -l "Section";
  313.  
  314.             intSliderGrp -label "Samples"
  315.                 -min 1 -max 32 -fmx 10000
  316.                 uNumber;
  317.  
  318.             optionMenuGrp -l "Along Curve" vType;
  319.                 menuItem -l "Complete";
  320.                 menuItem -l "Span";
  321.  
  322.             intSliderGrp -label "Samples"
  323.                 -min 1 -max 32 -fmx 10000
  324.                 vNumber;
  325.  
  326.             columnLayout secondary;
  327.                 separator -w 1000;
  328.                 text -l " Secondary Controls";
  329.                 checkBoxGrp -ncb 1 -l1 "Use Chord Height" useChordHeight;
  330.                 floatSliderGrp -l "Chord Height"
  331.                     -fmn 0.01 -fmx 0.2 -min 0.01 -max 0.2
  332.                     chordHeight;
  333.  
  334.                 checkBoxGrp -ncb 1 -l1 "Use Chord Height Ratio"
  335.                     useChordHeightRatio;
  336.                 floatSliderGrp -l "Chord Height Ratio"
  337.                     -min 0.01 -max 0.2 -fmn 0.01 -fmx 1.0
  338.                     ratioG;
  339.             setParent ..;
  340.  
  341.         setParent ..;
  342.  
  343.         columnLayout tabCount;
  344.             intSliderGrp -label "Face Count"
  345.                 -min 1 -max 1000 -fmx 1000000
  346.                 count;
  347.         setParent ..;
  348.  
  349.         columnLayout tabNothing;
  350.         setParent ..;
  351.     setParent ..;
  352. }
  353.  
  354. proc string createBevelOutputOptions(string $parent,
  355.     int $inTheTool, string $goToTool)
  356. {
  357.     string $form, $column, $outputTabs;
  358.  
  359.     setParent $parent;
  360.     
  361.     $form = `formLayout`;
  362.  
  363.     $column = `columnLayout/* -rowSpacing 2*/`;
  364.  
  365.     if( `isTrue "SurfaceUIExists"` ) {
  366.         radioButtonGrp -nrb 2 -label "Output Geometry"
  367.           -label1 "Nurbs" -da1 0
  368.           -label2 "Polygons" -da2 1 -select 1
  369.           -cc1 "bevelPlusVisibility(); tabLayout -e -st bevelPlusPolyOptionsNo bevelPlusPolyOptions"
  370.           -cc2 "bevelPlusVisibility(); tabLayout -e -st bevelPlusPolyOptionsOK bevelPlusPolyOptions"
  371.           outputPolyRadioButtonGrp;
  372.     }
  373.  
  374.     separator;
  375.  
  376.     tabLayout -tabsVisible false bevelPlusPolyOptions;
  377.       string $par = `columnLayout bevelPlusPolyOptionsOK`;
  378.         bevelPlusPolyAddOptions($par);
  379.       setParent ..;
  380.       columnLayout bevelPlusPolyOptionsNo;
  381.       setParent ..;
  382.     setParent ..;
  383.  
  384.     if( $inTheTool ) {
  385.         separator;
  386.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  387.           -l1 "Exit on Completion"
  388.           -v1 off
  389.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  390.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  391.  
  392.           -l2 "Auto Completion"
  393.           -v2 on
  394.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  395.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  396.           scriptToolExtraWidget;
  397.     }
  398.  
  399.     return $form;
  400. }
  401.  
  402. proc string assembleCmd()
  403. //
  404. //    Description :
  405. //        To assemble style bevel proc.
  406. //
  407. {
  408.     setOptionVars(false);
  409.     string $cmd = "bevelPlusPreset"  ;
  410.     $cmd = $cmd + "(" ;  
  411.  
  412.     int $history = `constructionHistory -q -tgl`;
  413.     $cmd = $cmd + $history ;  
  414.     $cmd = $cmd + "," ;  
  415.  
  416.     int $polygons = `optionVar -q bevelPlusOutputPolygons` ;
  417.     if( $polygons > 2 ) {
  418.         $polygons = 1;
  419.     }
  420.     if( !`isTrue "SurfaceUIExists"` ) $polygons = 1;
  421.     $cmd = $cmd + $polygons ;  
  422.     $cmd = $cmd + "," ;  
  423.  
  424.     int $bevelJoin = `optionVar -q bevelPlusAttachSurfaces` ;
  425.     $cmd = $cmd + $bevelJoin ;  
  426.     $cmd = $cmd + "," ;  
  427.  
  428.     float $tol = `optionVar -q bevelPlusTolerance` ;
  429.     if( `optionVar -q bevelPlusUseGlobalTol` ) {
  430.         $tol = `optionVar -q positionalTolerance`;
  431.     }
  432.     $cmd = $cmd + $tol ;  
  433.     $cmd = $cmd + "," ;
  434.   
  435.     int $bevelPlusSides = `optionVar -q bevelPlusNSides` ;
  436.     $cmd = $cmd + $bevelPlusSides ;  
  437.     $cmd = $cmd + "," ;  
  438.  
  439.     float $bevelPlusWidth = `optionVar -q bevelPlusWidth` ;
  440.     $cmd = $cmd + $bevelPlusWidth ;  
  441.     $cmd = $cmd + "," ;  
  442.  
  443.     float $bevelPlusDepth = `optionVar -q bevelPlusDepth` ;
  444.     $cmd = $cmd + $bevelPlusDepth ;
  445.     $cmd = $cmd + "," ;  
  446.  
  447.     float $bevelPlusExtrudeHt = `optionVar -q bevelPlusExtrudeHeight` ;
  448.     $cmd = $cmd + $bevelPlusExtrudeHt ;  
  449.     $cmd = $cmd + "," ;  
  450.  
  451.     int $bevelPlusCaps = `optionVar -q bevelPlusCaps` ;
  452.     $cmd = $cmd + $bevelPlusCaps ;
  453.     $cmd = $cmd + "," ;  
  454.  
  455.     int $outerBevelCurve = `optionVar -q outerStyleBevelCurve`;
  456.     $cmd = $cmd + $outerBevelCurve;  
  457.     $cmd = $cmd + "," ;  
  458.  
  459.     int $sameAsOuter = `optionVar -q innerStyleSameAsOuter`;
  460.     if( $sameAsOuter ) {
  461.         $cmd = $cmd + $outerBevelCurve ;  
  462.     }
  463.     else {
  464.         int $innerBevelCurve = `optionVar -q innerStyleBevelCurve`;
  465.         $cmd = $cmd + $innerBevelCurve ;  
  466.     }
  467.     $cmd = $cmd + ",";
  468.  
  469.     int $pFormat = `optionVar -q bevelPlusPolyFormat`;
  470.     $cmd = $cmd + $pFormat;
  471.     $cmd = $cmd + ",";
  472.  
  473.     int $pCount = `optionVar -q bevelPlusPolyCount`;
  474.     $cmd = $cmd + $pCount;
  475.     $cmd = $cmd + ",";
  476.  
  477.     int $pUseChordRatio = `optionVar -q bevelPlusPolyUseChordRatio`;
  478.     $cmd = $cmd + $pUseChordRatio;
  479.     $cmd = $cmd + ",";
  480.  
  481.     float $pChordRatio = `optionVar -q bevelPlusPolyChordRatio`;
  482.     $cmd = $cmd + $pChordRatio;
  483.     $cmd = $cmd + ",";
  484.  
  485.     int $pUseChordHeight = `optionVar -q bevelPlusPolyUseChordHeight`;
  486.     $cmd = $cmd + $pUseChordHeight;
  487.     $cmd = $cmd + ",";
  488.  
  489.     float $pChordHeight = `optionVar -q bevelPlusPolyChordHeight`;
  490.     $cmd = $cmd + $pChordHeight;
  491.     $cmd = $cmd + ",";
  492.  
  493.     int $pTypeU = `optionVar -q bevelPlusPolyTypeU`;
  494.     $cmd = $cmd + $pTypeU;
  495.     $cmd = $cmd + ",";
  496.  
  497.     int $pNumberU = `optionVar -q bevelPlusPolyNumberU`;
  498.     $cmd = $cmd + $pNumberU;
  499.     $cmd = $cmd + ",";
  500.  
  501.     int $pTypeV = `optionVar -q bevelPlusPolyTypeV`;
  502.     $cmd = $cmd + $pTypeV;
  503.     $cmd = $cmd + ",";
  504.  
  505.     int $pNumberV = `optionVar -q bevelPlusPolyNumberV`;
  506.     $cmd = $cmd + $pNumberV;
  507.  
  508.     $cmd = $cmd + ")" ;  
  509.  
  510.     // centre the pivot point
  511.     $cmd = $cmd + "; CenterPivot";
  512.  
  513.     //do a planar projection on the cap if outputting polys
  514.     if (`optionVar -q bevelPlusOutputPolygons` == 1){
  515.         
  516.         $cmd = $cmd + ";";
  517.         //must check to see if bevel has succeeded
  518.         //$bevelSuccess will be >0 if successful and command
  519.         //may continue
  520.  
  521.         string $errorCheck = " int $intArr[] = `polyEvaluate -v`; ";
  522.         $errorCheck += "int $numVerts = 0; ";
  523.         $errorCheck += "if (size($intArr) > 0) $numVerts = $intArr[0]; ";
  524.         $errorCheck += "if ($numVerts > 0) { ";
  525.         $cmd = $cmd + $errorCheck;
  526.         
  527.         //select all faces with 0 map area and more than 4 sides - these
  528.         //will be the caps
  529.         //see polyCleanupArgList.mel for a complete list of the arguments
  530.         $cmd = $cmd + "polyCleanupArgList 3 { \"0\",\"2\",\"1\",\"0\",";
  531.         $cmd = $cmd + "\"1\",\"0\",\"0\",\"0\",\"0\",\"1e-005\",\"0\",\"";
  532.         $cmd = $cmd + "1e-005\",\"1\",\"0\",\"0\",\"-1\",\"0\" };";
  533.         $cmd = $cmd + "polyProjection -ch 1 -type Planar -ibd off -icx 0.5 ";
  534.         $cmd = $cmd + "-icy 0.5 -ra 0 -isu 1 -isv 1 -md z ;";
  535.         $cmd = $cmd + "select -r `listConnections -t \"shape\"`;";
  536.  
  537.         $cmd = $cmd + "};";
  538.  
  539.         //and switch back to object mode
  540.         $cmd = $cmd + "changeSelectMode -object;";
  541.     }
  542.  
  543.     return $cmd ;
  544. }
  545.  
  546. proc bevelPlusOptions( int $inTheTool, string $goToTool )
  547. {
  548.     //    Name of the command for this option box.
  549.     //
  550.     string $commandName = "bevelPlus";
  551.  
  552.     //    Build the option box actions.
  553.     //
  554.     string $callback = ($commandName + "Callback");
  555.     string $setup = ($commandName + "Setup");
  556.  
  557.     global string $gOptionBoxActionToolItem;
  558.     $gOptionBoxActionToolItem = "modelWithToolBevelPlus";
  559.     global string $gOptionBoxActionToolItemCB;
  560.     $gOptionBoxActionToolItemCB = "bevelPlusToolScript 3";
  561.  
  562.     //    Turn on the wait cursor.
  563.     //
  564.     waitCursor -state 1;
  565.  
  566.     //    Step 1:  Get the option box.
  567.     //    ============================
  568.     string $layout = getOptionBox();
  569.     setParent $layout;
  570.     
  571.     //    Step 2:  Pass the command name to the option box.
  572.     //    =================================================
  573.     setOptionBoxCommandName($commandName);
  574.     
  575.  
  576.     //    Step 3:  Activate the default UI template.
  577.     //    ==========================================
  578.  
  579.     setUITemplate -pushTemplate DefaultTemplate;
  580.  
  581.     //    Step 4: Create option box contents.
  582.     //    ===================================
  583.  
  584.     string $bevelOptionsLayout;
  585.     string $outputOptionsLayout;
  586.  
  587.     string $parent = `tabLayout -scrollable true`;
  588.  
  589.     $bevelOptionsLayout = createBevelOptions($parent);
  590.     $outputOptionsLayout =  createBevelOutputOptions($parent, $inTheTool, $goToTool );
  591.  
  592.     tabLayout -edit
  593.         -tabLabel $bevelOptionsLayout "Bevel"
  594.         -tabLabel $outputOptionsLayout "Output Options"
  595.         $parent;
  596.  
  597.     //    Turn off the wait cursor.
  598.     //
  599.     waitCursor -state 0;
  600.     
  601.     //    Step 5: Deactivate the default UI template.
  602.     //  ===========================================
  603.     //
  604.     setUITemplate -popTemplate;
  605.  
  606.     //    Step 6: Customize the buttons.  
  607.     //    ==============================
  608.  
  609.     //    'Apply' button.
  610.     //
  611.     string $applyBtn = getOptionBoxApplyBtn();
  612.     if( $inTheTool ) {
  613.         button -edit -l "Bevel Tool"
  614.           -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  615.           $applyBtn;
  616.     }
  617.     else {
  618.         button -edit -l "Bevel"
  619.           -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  620.           $applyBtn;
  621.     }
  622.  
  623.     //    'Save' button.
  624.     //
  625.     string $saveBtn = getOptionBoxSaveBtn();
  626.     button -edit 
  627.         -command ($callback + " " + $parent + " 0 \"" +
  628.                   $goToTool + "\"; hideOptionBox")
  629.         $saveBtn;
  630.  
  631.     //    'Reset' button.
  632.     //
  633.     string $resetBtn = getOptionBoxResetBtn();
  634.     button -edit 
  635.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  636.         $resetBtn;
  637.  
  638.     //    Step 7: Set the option box title.
  639.     //    =================================
  640.     //
  641.     if( $inTheTool ) {
  642.         setOptionBoxTitle("Bevel Plus Tool Options");
  643.     }
  644.     else {
  645.         setOptionBoxTitle("Bevel Plus Options");
  646.     }
  647.  
  648.     //    Step 8: Customize the 'Help' menu item text.
  649.     //    ============================================
  650.     //
  651.     setOptionBoxHelpTag( "BevelPlus" );
  652.  
  653.     //    Step 9: Set the current values of the option box.
  654.     //    =================================================
  655.     //
  656.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  657.     
  658.     //    Step 10: Show the option box.
  659.     //    =============================
  660.     //
  661.     showOptionBox();
  662. }
  663.  
  664. proc string bevelPlusHelp()
  665. {
  666.     string $cmdHelp = "Command: Bevel Plus - creates a styled beveled surface. \n " ;
  667.     string $selectHelp = "Selection: Select a curve or surface isoparm or curve on surface to bevel " ;
  668.     return $cmdHelp+$selectHelp ;
  669. }
  670.  
  671. global proc bevelPlusSetup( string $parent,
  672.                         int $forceFactorySettings,
  673.                         string $goToTool)
  674. {
  675.     // retrieve option settings.
  676.     //
  677.     setOptionVars($forceFactorySettings);    
  678.     bevelPlusToolSetup( $forceFactorySettings, $goToTool );
  679.  
  680.     setParent $parent;    
  681.  
  682.     // query and set controls for all the option vars.
  683.     //
  684.     float $bwidth = `optionVar -q bevelPlusWidth` ;
  685.     floatSliderGrp -e -v $bwidth BevelWidthSliderGroup ;
  686.     if( $forceFactorySettings ) {
  687.         floatSliderGrp -e
  688.             -min 0.00001 -max 0.25 -fmn -10000.0 -fmx 10000.0
  689.             BevelWidthSliderGroup ;
  690.     }
  691.  
  692.     // bevel depth.
  693.     //
  694.     float $bdepth = `optionVar -q bevelPlusDepth` ;
  695.     floatSliderGrp -e -v $bdepth BevelDepthSliderGroup ;
  696.     if( $forceFactorySettings ) {
  697.         floatSliderGrp -e
  698.             -min 0.00001 -max 0.25 -fmn -10000.0 -fmx 10000.0
  699.             BevelDepthSliderGroup;
  700.     }
  701.  
  702.     // extrude height.
  703.     //
  704.     float $edepth = `optionVar -q bevelPlusExtrudeHeight` ;
  705.     floatSliderGrp -e -v $edepth extrudeDepthFloatField ;
  706.     if( $forceFactorySettings ) {
  707.         floatSliderGrp -e
  708.             -min 0.00001 -max 1.0 -fmn -10000.0 -fmx 10000.0
  709.             extrudeDepthFloatField;
  710.     }
  711.  
  712.     // global vs. local tolerance.
  713.     int $useGlobalTol = `optionVar -q bevelPlusUseGlobalTol`;
  714.     radioButtonGrp -e -select (2 - $useGlobalTol) useGlobalTol;
  715.  
  716.     // bevel tolerance.
  717.     //
  718.     float $tol = `optionVar -q bevelPlusTolerance` ;
  719.     floatSliderGrp -e -v $tol bevelPlusToleranceFloatField ;
  720.     if( $forceFactorySettings ) {
  721.         floatSliderGrp -e
  722.             -min 0.00001 -max 0.1 -fmn 0.00001 -fmx 1000.0
  723.             bevelPlusToleranceFloatField;
  724.     }
  725.  
  726.     if( $useGlobalTol == 1 ) {
  727.         tabLayout -e -selectTab noSlider useGlobalTolTab;
  728.     }
  729.     else {
  730.         tabLayout -e -selectTab showSlider useGlobalTolTab;
  731.     }
  732.  
  733.     // attach the surfaces.
  734.     //
  735.     int $attach = `optionVar -q bevelPlusAttachSurfaces` ;
  736.  
  737.     if( $attach == 1 ) {
  738.         checkBoxGrp -edit -v1 true bevelPlusJoinSrfBox  ;
  739.     } else {
  740.         checkBoxGrp -edit -v1 false bevelPlusJoinSrfBox  ;
  741.     }
  742.  
  743.     // Outer Bevel Curve Name
  744.     //
  745.     int $styleCurve = `optionVar -q outerStyleBevelCurve` ;
  746.     textScrollList -edit -sii ($styleCurve+1) BevelOuterStyleTextScrollList;
  747.  
  748.     // Inner Bevel Curve Name
  749.     //
  750.     $styleCurve = `optionVar -q innerStyleBevelCurve` ;
  751.     textScrollList -edit -sii ($styleCurve+1) BevelInnerStyleTextScrollList;
  752.  
  753.     // Inner bevel same as outer bevel
  754.     //
  755.     int $sameAsOuterStyle = `optionVar -q innerStyleSameAsOuter` ;
  756.     checkBoxGrp -edit -v1 $sameAsOuterStyle BevelInnerStyleCheckBoxGroup;
  757.  
  758.     // polygon output.
  759.     //
  760.     int $polygons = `optionVar -q bevelPlusOutputPolygons`;
  761.     if( !`isTrue "SurfaceUIExists"` ) {
  762.         $polygons = 1;
  763.     } else {
  764.         switch( $polygons ) {
  765.           case 0:
  766.             radioButtonGrp -edit -select 1 outputPolyRadioButtonGrp;
  767.             break;
  768.           case 1:
  769.             radioButtonGrp -edit -select 2 outputPolyRadioButtonGrp;
  770.             break;
  771.           case 2:
  772.             warning("Invalid choice");
  773.             break;
  774.           case 3:
  775.             radioButtonGrp -edit -select 3 outputPolyRadioButtonGrp;
  776.             break;
  777.           default:
  778.             break;
  779.         }
  780.     }
  781.  
  782.     bevelPlusVisibility();
  783.  
  784.     int $nedges = `optionVar -q bevelPlusNSides` ;
  785.     
  786.     if( $nedges == 1 ) {
  787.         //None
  788.         checkBoxGrp -e -v1 0 BevelSideCheckBoxGroup;
  789.         checkBoxGrp -e -v2 0 BevelSideCheckBoxGroup;
  790.     } else if( $nedges == 4 ) {
  791.         //At Start and End
  792.         checkBoxGrp -e -v1 1 BevelSideCheckBoxGroup;
  793.         checkBoxGrp -e -v2 1 BevelSideCheckBoxGroup;
  794.     } else if( $nedges == 3 ) {
  795.         //At End
  796.         checkBoxGrp -e -v1 0 BevelSideCheckBoxGroup;
  797.         checkBoxGrp -e -v2 1 BevelSideCheckBoxGroup;
  798.     } else if( $nedges == 2 ) {
  799.         //At Start
  800.         checkBoxGrp -e -v1 1 BevelSideCheckBoxGroup;
  801.         checkBoxGrp -e -v2 0 BevelSideCheckBoxGroup;
  802.     }
  803.  
  804.     int $ncaps = `optionVar -q bevelPlusCaps` ;
  805.     
  806.     if( $ncaps == 1 ) {
  807.         //None
  808.         checkBoxGrp -e -v1 0 BevelCapCheckBoxGroup;
  809.         checkBoxGrp -e -v2 0 BevelCapCheckBoxGroup;
  810.     } else if( $ncaps == 4 ) {
  811.         //At Start and End
  812.         checkBoxGrp -e -v1 1 BevelCapCheckBoxGroup;
  813.         checkBoxGrp -e -v2 1 BevelCapCheckBoxGroup;
  814.     } else if( $ncaps == 3 ) {
  815.         //At End
  816.         checkBoxGrp -e -v1 0 BevelCapCheckBoxGroup;
  817.         checkBoxGrp -e -v2 1 BevelCapCheckBoxGroup;
  818.     } else if( $ncaps == 2 ) {
  819.         //At Start
  820.         checkBoxGrp -e -v1 1 BevelCapCheckBoxGroup;
  821.         checkBoxGrp -e -v2 0 BevelCapCheckBoxGroup;
  822.     }
  823.  
  824.     // dim/show any options as required
  825.     //
  826.     BevelSideCheckBoxChange();
  827.  
  828.     switch( $polygons ) {
  829.       case 0:
  830.       default:
  831.         tabLayout -e -st bevelPlusPolyOptionsNo bevelPlusPolyOptions;
  832.         break;
  833.       case 1:
  834.         tabLayout -e -st bevelPlusPolyOptionsOK bevelPlusPolyOptions;
  835.         break;
  836.     }
  837.  
  838.     if( "" != $goToTool ) { 
  839.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  840.           scriptToolExtraWidget;
  841.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  842.           scriptToolExtraWidget;
  843.     }
  844.  
  845.     // Now the polygon options:
  846.     int $formatValue;
  847.     int $localIntValue;
  848.     float $localFloatValue;
  849.  
  850.     $formatValue = `optionVar -q bevelPlusPolyFormat`;
  851.     switch( $formatValue ) {
  852.       case 0:
  853.         radioButtonGrp -e -sl 1 format;
  854.         break;
  855.       case 2:
  856.         radioButtonGrp -e -sl 2 format;
  857.         break;
  858.       default:
  859.         break;
  860.     }
  861.  
  862.     $localIntValue = `optionVar -q bevelPlusPolyCount`;
  863.     intSliderGrp -e -v $localIntValue count;
  864.  
  865.     $localFloatValue = `optionVar -q bevelPlusPolyChordRatio`;
  866.     floatSliderGrp -e -v $localFloatValue ratioG;
  867.  
  868.     $localIntValue = `optionVar -q bevelPlusPolyTypeU`;
  869.     optionMenuGrp -e -sl ($localIntValue-1) uType;
  870.  
  871.     $localIntValue = `optionVar -q bevelPlusPolyNumberU`;
  872.     intSliderGrp -e -v $localIntValue uNumber;
  873.  
  874.     $localIntValue = `optionVar -q bevelPlusPolyTypeV`;
  875.     optionMenuGrp -e -sl ($localIntValue-1) vType;
  876.  
  877.     $localIntValue = `optionVar -q bevelPlusPolyNumberV`;
  878.     intSliderGrp -e -v $localIntValue vNumber;
  879.  
  880.     $localIntValue = `optionVar -q bevelPlusPolyUseChordHeight`;
  881.     checkBoxGrp -e -v1 $localIntValue useChordHeight;
  882.  
  883.     $localFloatValue = `optionVar -q bevelPlusPolyChordHeight`;
  884.     floatSliderGrp -e -v $localFloatValue chordHeight;
  885.  
  886.     $localIntValue = `optionVar -q bevelPlusPolyUseChordRatio`;
  887.     checkBoxGrp -e -v1 $localIntValue useChordHeightRatio;
  888.  
  889.     bevelPlusPolyVisibility $parent $formatValue;
  890. }
  891.  
  892. global proc bevelPlusCallback( string $parent, int $doIt, string $goToTool )
  893. {
  894.     if( "" != $goToTool ) {
  895.         optionVar -iv bevelPlusEuc `scriptCtx -q -euc $goToTool`;
  896.         optionVar -iv bevelPlusLac `scriptCtx -q -lac $goToTool`;
  897.     }
  898.  
  899.     setParent $parent ;
  900.  
  901.     // get Values from controls.
  902.     //
  903.     if( `isTrue "SurfaceUIExists"` ) {
  904.         int $polys = `radioButtonGrp -q -select outputPolyRadioButtonGrp`;
  905.         if( 3 == $polys ) {
  906.             $polys = 4;
  907.         }
  908.         optionVar -intValue bevelPlusOutputPolygons ($polys-1) ;
  909.     }
  910.  
  911.     // global vs. local
  912.     int $useGlobalTol = 2 - `radioButtonGrp -q -select useGlobalTol`;
  913.     optionVar -intValue bevelPlusUseGlobalTol $useGlobalTol;
  914.  
  915.     float $fValue = `floatSliderGrp -q -v bevelPlusToleranceFloatField` ;
  916.     optionVar -floatValue bevelPlusTolerance $fValue ;
  917.  
  918.     $fValue = `floatSliderGrp -q -v BevelWidthSliderGroup` ;
  919.     optionVar -floatValue bevelPlusWidth $fValue ;
  920.  
  921.     $fValue = `floatSliderGrp -q -v BevelDepthSliderGroup` ;
  922.     optionVar -floatValue bevelPlusDepth $fValue ;
  923.  
  924.     $fValue = `floatSliderGrp -q -v extrudeDepthFloatField` ;
  925.     optionVar -floatValue bevelPlusExtrudeHeight $fValue;
  926.  
  927.     // attach surfaces or not.
  928.     //
  929.     int $val = `checkBoxGrp -q -v1 bevelPlusJoinSrfBox` ;
  930.     optionVar -intValue bevelPlusAttachSurfaces $val ;
  931.  
  932.     // bevel number of edges.
  933.     //
  934.     int $ne;
  935.     int $atStart = `checkBoxGrp -q -v1 BevelSideCheckBoxGroup`;
  936.     int $atEnd = `checkBoxGrp -q -v2 BevelSideCheckBoxGroup`;
  937.     if( !$atStart && !$atEnd ) {
  938.         //None
  939.         $ne = 1;
  940.     }
  941.     else if( $atStart && !$atEnd ) {
  942.         //At Start
  943.         $ne = 2;
  944.     }
  945.     else if( !$atStart && $atEnd ) {
  946.         //At End
  947.         $ne = 3;
  948.     }
  949.     else if( $atStart && $atEnd ) {
  950.         //At Start and End
  951.         $ne = 4;
  952.     }
  953.     optionVar -intValue bevelPlusNSides $ne ;
  954.  
  955.     // bevel number of caps.
  956.     //
  957.     int $nCaps;
  958.     $atStart = `checkBoxGrp -q -v1 BevelCapCheckBoxGroup`;
  959.     $atEnd = `checkBoxGrp -q -v2 BevelCapCheckBoxGroup`;
  960.     if( !$atStart && !$atEnd ) {
  961.         //None
  962.         $nCaps = 1;
  963.     }
  964.     else if( $atStart && !$atEnd ) {
  965.         //At Start
  966.         $nCaps = 2;
  967.     }
  968.     else if( !$atStart && $atEnd ) {
  969.         //At End
  970.         $nCaps = 3;
  971.     }
  972.     else if( $atStart && $atEnd ) {
  973.         //At Start and End
  974.         $nCaps = 4;
  975.     }
  976.     optionVar -intValue bevelPlusCaps $nCaps;
  977.  
  978.     // Outer bevel Curve
  979.     //
  980.     int $styleCurve[] = `textScrollList -q -sii BevelOuterStyleTextScrollList`;
  981.     optionVar -intValue outerStyleBevelCurve ($styleCurve[0]-1);
  982.  
  983.     // Inner bevel Curve
  984.     //
  985.     $styleCurve = `textScrollList -q -sii BevelInnerStyleTextScrollList`;
  986.     optionVar -intValue innerStyleBevelCurve ($styleCurve[0]-1);
  987.  
  988.     // Inner Bevel Same as Outer
  989.     //
  990.     int $sameAsOuterStyle = `checkBoxGrp -q -v1 BevelInnerStyleCheckBoxGroup`;
  991.     optionVar -intValue innerStyleSameAsOuter $sameAsOuterStyle;
  992.  
  993.     // Output options
  994.     //
  995.     int $formatValue = `radioButtonGrp -q -sl format`;
  996.     switch( $formatValue ) {
  997.       case 1:
  998.         $formatValue = 0;
  999.         break;
  1000.       case 2:
  1001.         $formatValue = 2;
  1002.         break;
  1003.       default:
  1004.         break;
  1005.     }
  1006.  
  1007.     optionVar -iv bevelPlusPolyFormat $formatValue;
  1008.     optionVar -iv bevelPlusPolyCount (`intSliderGrp -q -v count`);
  1009.     optionVar -fv bevelPlusPolyChordRatio (`floatSliderGrp -q -v ratioG`);
  1010.  
  1011.     optionVar -iv bevelPlusPolyTypeU (`optionMenuGrp -q -sl uType` + 1);
  1012.     optionVar -iv bevelPlusPolyNumberU (`intSliderGrp -q -v uNumber`);
  1013.     optionVar -iv bevelPlusPolyTypeV (`optionMenuGrp -q -sl vType` + 1);
  1014.     optionVar -iv bevelPlusPolyNumberV (`intSliderGrp -q -v vNumber`);
  1015.     optionVar -iv bevelPlusPolyUseChordHeight (`checkBoxGrp -q -v1 useChordHeight`);
  1016.     optionVar -fv bevelPlusPolyChordHeight (`floatSliderGrp -q -v chordHeight`);
  1017.     optionVar -iv bevelPlusPolyUseChordRatio (`checkBoxGrp -q -v1 useChordHeightRatio`);
  1018.  
  1019.     if( 1 == $doIt ) {
  1020.         performBevelPlus(0, $goToTool); 
  1021.         string $tmpCmd = "performBevelPlus(0, \"" + $goToTool + "\")";
  1022.         addToRecentCommandQueue $tmpCmd "BevelPlus";
  1023.     }
  1024.     else if( $doIt ) {
  1025.         setToolTo $goToTool;
  1026.     }
  1027. }
  1028.  
  1029. global proc string performBevelPlus( int $action, string $goToTool )
  1030. //
  1031. //    Description :
  1032. //        $action = 0 ==> do the command.
  1033. //        $action = 1 ==>show option box.
  1034. //        $action = 2 ==>drag to shelf.
  1035. //        $action = 3 ==>Show the tool option box
  1036. {
  1037.     int $inTheTool = false;
  1038.     if( 3 == $action ) {
  1039.         $action = 1;
  1040.         $inTheTool = true;
  1041.     }
  1042.  
  1043.     string $cmd = "" ;
  1044.     switch( $action ) {
  1045.       case 0:
  1046.         $cmd = `assembleCmd` ;
  1047.         //Turn on the wait cursor
  1048.         //
  1049.         if( catch(eval($cmd)) ){
  1050.         }
  1051.         break ;
  1052.       case 1:
  1053.         bevelPlusOptions( $inTheTool, $goToTool );
  1054.         break ;
  1055.       case 2:
  1056.       default:
  1057.         $cmd = `assembleCmd` ;
  1058.         break ;
  1059.     }
  1060.     return $cmd ;
  1061. }
  1062.  
  1063.